package br.com.consultsystems.dominio.financeiro;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import br.com.consultsystems.dominio.cadastro.Condominio;

@Entity
@Table(name = "conta")
@SequenceGenerator(name = "operacao", sequenceName = "operacao",  allocationSize = 1)
@XmlRootElement
public class Conta implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -5051966374981614688L;

	@Id
	@Column(name = "id", nullable = false, insertable = true, updatable = false)
	@GeneratedValue(generator = "operacao", strategy = GenerationType.SEQUENCE)
	private Long id;
	
	@Column(name = "nome", nullable = false, insertable = true, updatable = true, length = 200)
	private String nome;

	@Column(name = "agencia", nullable = false, insertable = true, updatable = true, length = 20)
	private String agencia;

	@Column(name = "agdv", nullable = false, insertable = true, updatable = true, length = 20)
	private String agdv;

	@Column(name = "conta", nullable = false, insertable = true, updatable = true, length = 20)
	private String conta;

	@Column(name = "codv", nullable = false, insertable = true, updatable = true, length = 20)
	private String codv;
	
	@ManyToOne
	@JoinColumn(name = "id_banco", nullable = false, insertable = true, updatable = true)
	private Banco banco;	

	@ManyToOne
	@JoinColumn(name = "id_condominio", nullable = false, insertable = true, updatable = true)
	private Condominio condominio;	
	
	public Conta() {
		super();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getAgencia() {
		return agencia;
	}

	public void setAgencia(String agencia) {
		this.agencia = agencia;
	}

	public String getAgdv() {
		return agdv;
	}

	public void setAgdv(String agdv) {
		this.agdv = agdv;
	}

	public String getConta() {
		return conta;
	}

	public void setConta(String conta) {
		this.conta = conta;
	}

	public String getCodv() {
		return codv;
	}

	public void setCodv(String codv) {
		this.codv = codv;
	}

	public Banco getBanco() {
		return banco;
	}

	public void setBanco(Banco banco) {
		this.banco = banco;
	}

	@Override
	public String toString() {
		return "Conta [id=" + id + ", nome=" + nome + ", agencia=" + agencia
				+ ", agdv=" + agdv + ", conta=" + conta + ", codv=" + codv
				+ ", banco=" + banco + ", condominio=" + condominio + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Conta other = (Conta) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
	
}
